libxc: osdep: convert xc_map_foreign_range()
authorIan Campbell <ian.campbell@citrix.com>
Fri, 3 Dec 2010 09:36:47 +0000 (09:36 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 3 Dec 2010 09:36:47 +0000 (09:36 +0000)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
tools/libxc/xc_foreign_memory.c
tools/libxc/xc_linux.c
tools/libxc/xc_minios.c
tools/libxc/xc_netbsd.c
tools/libxc/xc_solaris.c
tools/libxc/xenctrlosdep.h

index 953f63bbafb86f28e167e8f7adb9ee6747cc3a50..95d1d43c7807966ea5dcb9ea8324530d1bdb7021 100644 (file)
 
 #include "xc_private.h"
 
+void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
+                           int size, int prot, unsigned long mfn)
+{
+    return xch->ops->u.privcmd.map_foreign_range(xch, xch->ops_handle,
+                                                 dom, size, prot, mfn);
+}
+
 void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
-                           xen_pfn_t *arr, int num )
+                           xen_pfn_t *arr, int num)
 {
     return xch->ops->u.privcmd.map_foreign_batch(xch, xch->ops_handle,
                                                  dom, prot, arr, num);
@@ -33,3 +40,13 @@ void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
     return xch->ops->u.privcmd.map_foreign_bulk(xch, xch->ops_handle,
                                                 dom, prot, arr, err, num);
 }
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 76d47918457730d327beb520f26c7e018ee6194c..aa70cc8763533f2a37c88fe8a6d175f078dc6b29 100644 (file)
@@ -283,8 +283,9 @@ static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h
     return addr;
 }
 
-void *xc_map_foreign_range(xc_interface *xch, uint32_t dom, int size, int prot,
-                           unsigned long mfn)
+static void *linux_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
+                                             uint32_t dom, int size, int prot,
+                                             unsigned long mfn)
 {
     xen_pfn_t *arr;
     int num;
@@ -335,6 +336,7 @@ static struct xc_osdep_ops linux_privcmd_ops = {
 
         .map_foreign_batch = &linux_privcmd_map_foreign_batch,
         .map_foreign_bulk = &linux_privcmd_map_foreign_bulk,
+        .map_foreign_range = &linux_privcmd_map_foreign_range,
     },
 };
 
index 624889d19387aaecff7e80938d6cee928adf38db..83b5e324ecba9676974704bd8ef0a020d2089e06 100644 (file)
@@ -134,9 +134,10 @@ static void *minios_privcmd_map_foreign_batch(xc_interface *xch,  xc_osdep_handl
     return (void *) addr;
 }
 
-void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
-                           int size, int prot,
-                           unsigned long mfn)
+static void *minios_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
+                                              uint32_t dom,
+                                              int size, int prot,
+                                              unsigned long mfn)
 {
     unsigned long pt_prot = 0;
 #ifdef __ia64__
@@ -190,6 +191,7 @@ static struct xc_osdep_ops minios_privcmd_ops = {
 
         .map_foreign_batch = &minios_privcmd_map_foreign_batch,
         .map_foreign_bulk = &minios_privcmd_map_foreign_bulk,
+        .map_foreign_range = &minios_privcmd_map_foreign_range,
     },
 };
 
index 671ae2c3a67fbbdb6889fa108fd42d9f8f8956a4..00f4ffc2a347238f81bd2be40a9bdc229250a890 100644 (file)
@@ -108,10 +108,12 @@ static void *netbsd_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle
 
 }
 
-void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
-                           int size, int prot,
-                           unsigned long mfn)
+static void *netbsd_privcmd_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
+                                              uint32_t dom,
+                                              int size, int prot,
+                                              unsigned long mfn)
 {
+    int fd = (int)h;
     privcmd_mmap_t ioctlx;
     privcmd_mmap_entry_t entry;
     void *addr;
@@ -127,7 +129,7 @@ void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
     entry.va=(unsigned long) addr;
     entry.mfn=mfn;
     entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
-    if ( ioctl(xch->fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
+    if ( ioctl(fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
     {
         int saved_errno = errno;
         PERROR("xc_map_foreign_range: ioctl failed");
@@ -183,6 +185,7 @@ static struct xc_osdep_ops netbsd_privcmd_ops = {
 
         .map_foreign_batch = &netbsd_privcmd_map_foreign_batch,
         .map_foreign_bulk = &xc_map_foreign_bulk_compat,
+        .map_foreign_range = &netbsd_privcmd_map_foreign_range,
     },
 };
 
index 8152868e7c97737122d0064e635ffc9037b0eb7c..d9af863c6e913e771740bb502d02ce59b4ea6501 100644 (file)
@@ -101,14 +101,16 @@ static void *solaris_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handl
 
 }
 
-void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
-                           int size, int prot,
-                           unsigned long mfn)
+static void *xc_map_foreign_range(xc_interface *xch, xc_osdep_handle h,
+                                  uint32_t dom,
+                                  int size, int prot,
+                                  unsigned long mfn)
 {
+    int fd = (int)fd;
     privcmd_mmap_t ioctlx;
     privcmd_mmap_entry_t entry;
     void *addr;
-    addr = mmap(NULL, size, prot, MAP_SHARED, xch->fd, 0);
+    addr = mmap(NULL, size, prot, MAP_SHARED, fd, 0);
     if ( addr == MAP_FAILED )
         return NULL;
 
@@ -118,7 +120,7 @@ void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
     entry.va=(unsigned long) addr;
     entry.mfn=mfn;
     entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT;
-    if ( ioctl(xch->fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
+    if ( ioctl(fd, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 )
     {
         int saved_errno = errno;
         (void)munmap(addr, size);
@@ -173,6 +175,7 @@ static struct xc_osdep_ops solaris_privcmd_ops = {
 
         .map_foreign_batch = &solaris_privcmd_map_foreign_batch,
         .map_foreign_bulk = &xc_map_foreign_bulk_compat,
+        .map_foreign_range = &solaris_privcmd_map_foreign_range,
     },
 };
 
index 204b9e87e96b16971622759e3c8a71e377fbce58..eadbbc0808487309a2b36d648c460e955c38e779 100644 (file)
@@ -68,6 +68,8 @@ struct xc_osdep_ops
                                        xen_pfn_t *arr, int num);
             void *(*map_foreign_bulk)(xc_interface *xch, xc_osdep_handle h, uint32_t dom, int prot,
                                       const xen_pfn_t *arr, int *err, unsigned int num);
+            void *(*map_foreign_range)(xc_interface *xch, xc_osdep_handle h, uint32_t dom, int size, int prot,
+                                       unsigned long mfn);
         } privcmd;
     } u;
 };